package com.tansun.easycare.rule.effect.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tansun.easycare.rule.codeblock.entity.RuleCodeblock;
import com.tansun.easycare.rule.codeblock.service.RuleCodeblockService;
import com.tansun.easycare.rule.datamodel.service.RuleDataparamsService;
import com.tansun.easycare.rule.deployonline.service.RuleDeployOnlineService;
import com.tansun.easycare.rule.rulemange.service.RuleManageService;

@Service
public class RuleEffectServiceImpl implements RuleEffectService{
    @Autowired
    private RuleCodeblockService ruleCodeblockService;
    @Autowired
    private RuleDataparamsService ruleDataparamsService;
    @Autowired
    private RuleManageService ruleManageService;
    @Autowired
    private RuleDeployOnlineService ruleDeployOnlineService;
    @Override
    public void doEffectNow(String projectCode, String modelType, String manageId) {
        if("1".equals(modelType)){
            RuleCodeblock condition = new RuleCodeblock();
            condition.setProjectCode(projectCode);
            condition.setParameterId(manageId);
            List<RuleCodeblock> rcb = ruleCodeblockService.findList(condition);
            ruleDataparamsService.complementApproval(new ArrayList<String>(){{add(rcb.get(0).getId());}});
        }else if("2".equals(modelType)){
            ruleManageService.updateActiveVersion(new ArrayList<String>(){{add(manageId);}});
        }else if("3".equals(modelType)){
            ruleDeployOnlineService.updateStatusIndById(new ArrayList<String>(){{add(manageId);}});
        }
    }
}
